package example.cdx.com.textureviewdemo;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import butterknife.BindView;
import butterknife.ButterKnife;
import example.cdx.com.textureviewdemo.activity.Test1Activity;

public class MainActivity extends AppCompatActivity {

    private Context mContext;

    @BindView(R.id.lv)
    ListView lv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initParamsAndValues();

        initView();

        initData();
    }

    private void initParamsAndValues() {
        mContext = this;
    }

    private void initView() {
        ButterKnife.bind(this);
        lv.setOnItemClickListener(mOnItemClickListener);
    }

    private void initData() {
        String[] data = new String[]{"TextureView用来绘制一个圆"};
        ArrayAdapter<String> adapter = new ArrayAdapter<>(mContext,android.R.layout.simple_list_item_1,data);
        lv.setAdapter(adapter);
    }

    AdapterView.OnItemClickListener mOnItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0){
                startActivity(new Intent(mContext,Test1Activity.class));
            }
        }
    };
}
